package com.example.gpssystem.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Email;

import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.redis.core.RedisHash;

import java.math.BigDecimal;
import java.time.LocalDateTime;


@RedisHash("Order") // 添加Redis哈希标识
@Data
@Document(collection = "orders") 
public class Order {
    @Id
    private String id;
    // 新增字段校验注解
    @NotBlank(message = "寄件人姓名不能为空")
    private String senderName;
    
    @NotBlank(message = "收件人姓名不能为空")
    private String receiverName;  // 新增收件人姓名字段
    
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;
    private BigDecimal shippingFee;
    private Double weight;
    private Double distance;
    @NotBlank(message = "寄件地址不能为空")
    private String senderAddress;

    @NotBlank(message = "收件地址不能为空") 
    private String receiverAddress;

//    @Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号格式错误")
    private String senderPhone;

//    @Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号格式错误")
    private String receiverPhone;
    
    @Email(message = "邮箱格式错误")
    private String senderEmail;
    
    private String packageType; // 包裹类型
    private String insuranceInfo; // 保价信息
    
    // 现有字段保持不变
    
    public enum OrderStatus {
        PICKED_UP,    // 已揽件
        IN_TRANSIT,   // 运输中
        DELIVERED     // 已签收
    }
    
    private OrderStatus status;
}